#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/shm.h>

#define IPC_F 0x89898989
int main()
{
    //创建或者获取一个共享内存
    int shmid = shmget(IPC_F,1024,IPC_CREAT | 0664);
    if(shmid < 0)
    {
        //创建或者获取失败
        perror("shmget");
        return 0;
    }
    //将共享内存附加到共享区间上去
    void* addr = shmat(shmid,NULL,0);
    if(addr == NULL)
    {
        //说明附加失败
        perror("shmat");
        return 0;
    }
    int count = 0;
    while(1)
    {
        
         char lp[1024] = "linux so easy";
         sprintf(lp,"%s-%d\n",lp,count++);
         strcpy((char*)addr,lp);
         sleep(1);
    }

    //删除
    
    
    return 0;
}
